#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct sty
{
	char name[20];
	int age;
};
int com_int(void const* p1, void const* p2)
{
	return *(int*)p1 - *(int*)p2;
}
int com_by_name(const void* p1, const void* p2)
{
	return strcmp(((struct sty*)p1)->name, ((struct sty*)p2)->name);
}
int com_float(const void* p1, const void* p2)
{
	return *(float*)p1 - *(float*)p2;
}
void print_int(int* arr, int sz)
{
	int i = 0;
	for (i = 0; i < sz; i++)
	{
		printf("%zd ", arr[i]);
	}
	printf("\n");
}
void print_char(struct sty* arr, int sz)
{
	int i = 0;
	for (i = 0; i < sz; i++)
	{
		printf("%s ", arr[i].name);
	}
	printf("\n");
}
void print_float(float* arr, int sz)
{
	int i = 0;
	for (i = 0; i < sz; i++)
	{
		printf("%f ", arr[i]);
	}
	printf("\n");
}
void test1()
{
	int arr[] = { 1,3,5,2,4,7,8,0,6,9 };
	size_t sz = sizeof(arr) / sizeof(arr[0]);
	qsort(arr, sz, sizeof(arr[0]), com_int);
	print_int(arr, sz);
}
void test2()
{
	struct sty arr[] = { {"lidage",19},{"fangwenn",18},{"xiaomei",20} };
	size_t sz = sizeof(arr) / sizeof(arr[0]);
	qsort(arr, sz, sizeof(arr[0]), com_by_name);
	print_char(arr, sz);
}
void test3()
{
	float arr[] = { 1.0,3.2,5.4,2.5,4.5,7.4 };
	size_t sz = sizeof(arr) / sizeof(arr[0]);
	qsort(arr, sz, sizeof(arr[0]), com_float);
	print_float(arr, sz);
}
int main()
{
	test1();
	test2();
	test3();
	return 0;
}